using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_TimetableMap : EntityTypeConfiguration<Tb_Timetable>
	{
		public Tb_TimetableMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			// Table & Column Mappings
			this.ToTable("Tb_Timetable");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.id_term).HasColumnName("id_term");
			this.Property(t => t.id_course).HasColumnName("id_course");
			this.Property(t => t.id_lecturer).HasColumnName("id_lecturer");
			this.Property(t => t.id_room).HasColumnName("id_room");
			this.Property(t => t.id_slot).HasColumnName("id_slot");
			this.Property(t => t.status).HasColumnName("status");
			this.Property(t => t.count).HasColumnName("count");

			// Relationships
			this.HasRequired(t => t.Tb_Config)
				.WithMany(t => t.Tb_Timetable)
				.HasForeignKey(d => d.id_term);
				
			this.HasRequired(t => t.Tb_Course)
				.WithMany(t => t.Tb_Timetable)
				.HasForeignKey(d => d.id_course);
				
			this.HasRequired(t => t.Tb_People)
				.WithMany(t => t.Tb_Timetable)
				.HasForeignKey(d => d.id_lecturer);
				
			this.HasRequired(t => t.Tb_Room)
				.WithMany(t => t.Tb_Timetable)
				.HasForeignKey(d => d.id_room);
				
			this.HasRequired(t => t.Tb_Slot)
				.WithMany(t => t.Tb_Timetable)
				.HasForeignKey(d => d.id_slot);
				
		}
	}
}

